package com.inventory.service.impl;

import java.util.List;
import javax.annotation.Resource;

import com.inventory.mapper.InventoryMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.inventory.service.InventoryService;
import com.inventory.entity.Inventory;

/**
 * 库存信息 业务逻辑实现类
 */
@Service
@Transactional
public class InventoryServiceImpl implements InventoryService {

    @Resource
    public InventoryMapper inventoryMapper;

    /**
     * 添加库存信息
     * @param inventory
     * @return
     */
    @Override
    public boolean doAddInventoryInfo(Inventory inventory) {
        //检查库存信息是否存在
        if(inventoryMapper.doGetInventoryInfo(inventory)==null) {
            //开始添加库存信息
            return inventoryMapper.doAddInventoryInfo(inventory)!=0;
        }
        return false;
    }

    /**
     * 修改库存信息
     * @param inventory
     * @return
     */
    @Override
    public boolean doModifyInventoryInfo(Inventory inventory) {
        return inventoryMapper.doModifyInventoryInfo(inventory)!=0;
    }

    /**
     * 删除库存信息
     * @param inventory
     * @return
     */
    @Override
    public boolean doDeleteInventoryInfo(Inventory inventory) {
        return inventoryMapper.doDeleteInventoryInfo(inventory)!=0;
    }

    /**
     * 获取库存信息
     * @param inventory
     * @return
     */
    @Override
    public Inventory doGetInventoryInfo(Inventory inventory) {
        return inventoryMapper.doGetInventoryInfo(inventory);
    }

    /**
     * 获取库存列表
     * @return
     */
    @Override
    public List<Inventory> doGetInventoryInfoList() {
        return inventoryMapper.doGetInventoryInfoList();
    }

    /**
     * 查询库存列表
     * @param inventory
     * @return
     */
    @Override
    public List<Inventory> doQueryInventoryInfoList(Inventory inventory) {
        return inventoryMapper.doQueryInventoryInfoList(inventory);
    }

}